package com.xindacloud.sms.adapter.utils;

import java.security.MessageDigest;

/**
 * Created with IntelliJ IDEA
 * User: 张家喻
 * Date: 2020/3/22
 * Time: 23:49
 * Description:
 */
public class HMACMD5Util {

    public static String encryption(String plainText) {
        String sign = "";
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(plainText.getBytes());
            byte b[] = md.digest();

            StringBuffer sb = new StringBuffer("");
            for (int i = 0; i < b.length; i++) {
                int v = b[i] & 0xff;
                if (v < 16) {
                    sb.append('0');
                }
                sb.append(Integer.toHexString(v));
            }
            sign = sb.toString();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return sign;
    }

}
